package com.ypj.indusynergyems.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ypj.indusynergyems.dao.entity.CartEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CartMapper extends BaseMapper<CartEntity> {


    //查询我的购物车
    @Select("select c.*,g.gods_name,g.gods_img,sd.shop_name from cart c LEFT JOIN" +
            " goods g on c.goods_id = g.gods_id LEFT JOIN shop sd on c.shop_id = sd.shop_id where c.user_id = #{userId}")
    List<CartEntity> findMyCartList(int userId);


    @Select("<script>" +
            "SELECT c.*, g.gods_name, g.gods_img, sd.shop_name " +
            "FROM cart c " +
            "LEFT JOIN goods g ON c.goods_id = g.gods_id " +
            "LEFT JOIN shop sd ON c.shop_id = sd.shop_id " +
            "WHERE c.id IN " +
            "<foreach item='id' index='index' collection='array' open='(' separator=',' close=')'>" +
            "#{id}" +
            "</foreach>" +
            "</script>")
    List<CartEntity> findMySelectGoodsList(int[] ints);
}
